package cn.org.xuanguang.kepler.hormos.orm.acl.impl;

import cn.org.xuanguang.kepler.hormos.orm.acl.PolicyCondition;
import cn.org.xuanguang.kepler.hormos.spring.starter.MultiTenantOptions;
import jakarta.validation.constraints.NotNull;

//模拟租户策略
public class KeplerTenantPolicy extends TenantPolicy {

    public String getPolicyName() {
        return "keplerTenant";
    }

    public KeplerTenantPolicy(@NotNull MultiTenantOptions multiTenant) {

        addPolicyCondition(
                PolicyCondition.builder()
                        .column(multiTenant.getTenantIdColumn())
                        .type("=")
                        // 此处应该从安全模块获取当前登录用户租户id
                        .value("tenantId")
                        .valueType(multiTenant.getTenantIdColumnType())
                        .desc("租户id")
                        .code(multiTenant.getTenantCode())
                        .build()
        );
    }
}
